<?php 
    $entities = pc_variable("entities");
    $typeName = pc_variable("typeName");
    $type = pc_config("type." . $typeName);
    $typeConfig = pc_config("cm.type." . $type->getFullName());
?>
<h2><?php pc_echo(pc_variable("title")); ?></h2>
<form action="./dispatcher.php" method="post">
    <fieldset>
        <?php if(!$entities->isEmpty()) { ?>
            <input type="hidden" name="typeName" value="<?php pc_echo($type->getFullName()); ?>"/>
            <?php foreach($entities as $entity) { ?>
            	<input type="hidden" name="ids[]" value="<?php pc_echo($entity->getId()); ?>"/>
            <?php } ?>
            <input type="hidden" name="targetPage.location" value="<?php pc_echo(pc_link("Query", array("typeName" => $type->getFullName()))); ?>"/>
            <p><?php pc_echo(pc_message("deleteEntity.confirmDelete", array(pc_message("namespace." . $typeName . ".plural")))); ?></p>
            <ul>
            <?php foreach($entities as $entity) { ?>
            	<li class="type-<?php pc_echo(Pageley_Util_String::splitCamelCase($type->getName(), "-")); ?>"><?php pc_echo($entity->get($typeConfig->getPrimaryPropertyName())); ?></li>
            <?php } ?>
            </ul>
        <?php } else { ?>
            <p><?php pc_echo(pc_message("deleteEntity.noEntitiesSelected", array(pc_message("namespace." . $typeName . ".plural")))); ?></p>
        <?php  } ?>
    </fieldset>
    <fieldset class="buttons">
        <?php if(!$entities->isEmpty()) { ?>
            <button class="delete" type="submit" name="controller" value="Delete"><?php pc_echo(pc_message("deleteEntity.delete")); ?></button>
        <?php } ?>
        <a href="<?php pc_echo(pc_link("Query", array("typeName" => $type->getFullName()))); ?>" class="cancel"/><?php pc_echo(pc_message("showEntity.cancel")); ?></a>
    </fieldset>
</form>
